
<script>
function doubleclick(el, code) {
            if (el.getAttribute("data-dblclick") == null) {
                el.setAttribute("data-dblclick", 1);
                setTimeout(function () {
                    if (el.getAttribute("data-dblclick") == 1) {
                 //       onsingle();
                    }
                    el.removeAttribute("data-dblclick");
                }, 300);
            } else {
                el.removeAttribute("data-dblclick");
                location.href='{$smarty.const.base_admin}?act=edit-post&id='+code;
            }
        }
function showhome(id,checked)
{
var val=0;
if(checked==true) val=1;
$.get( "{$smarty.const.base_admin}?act=manager-post&ajax=showhome&id="+id+"&value="+val, function( data ) {
	showhtml(id,checked,data);
});
}
function showtrailer(id,checked,parent)
{
var val=0;
if(checked==true) val=1;
$.get( "{$smarty.const.base_admin}?act=manager-post&ajax=showtrailer&id="+id+"&value="+val+"&parent="+parent, function( data ) {
	if(data!=0){
		$("#c_showtrailer"+id).prop('checked', (checked?false:true));
	}
	else
	{
			$(".c_showtrailer"+parent).prop('checked', false);
			$("#c_showtrailer"+id).prop('checked', checked);
	}
	showhtml(id,checked,data);
});
}
function showhtml(id,checked,code)
{
var data=[];
	data[0]="Cập nhật thành công!";
	data[1]="Có lỗi xảy ra";
	data[2]="Có lỗi: <br>Link Trailer của bài viết đang bị để chống";
	if(code==0)
	$("#msg"+id).css({ "background":"rgba(102, 255, 153,0.6)","color":"#ff0000"});
	else
		$("#msg"+id).css({ "background":"rgba(255, 102, 102,0.6)","color":"#6666cc"});
	$("#msg"+id).html("<div style=' display: table-cell; vertical-align: middle;height:"+$("#msg"+id).height()+"px;width:"+$("#msg"+id).width()+"px;'>"+data[code]+"</div>");
	$("#msg"+id).slideDown("slow");
	$("#msg"+id).animate({
		opacity:'0.4',
	},"fast");
	$("#msg"+id).animate({
		opacity:'1',
	},"slow");
	$("#msg"+id).delay(3000).slideUp("slow");
}
</script>	<!-- BEGIN PAGE CONTAINER-->
         <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->   
            <div class="row-fluid">
               <div class="span12">
                   <!-- BEGIN THEME CUSTOMIZER-->
                   <div id="theme-change" class="hidden-phone">
                       <i class="icon-cogs"></i>
                        <span class="settings">
                            <span class="text">Theme Color:</span>
                            <span class="colors">
                                <span class="color-default" data-style="default"></span>
                                <span class="color-green" data-style="green"></span>
                                <span class="color-gray" data-style="gray"></span>
                                <span class="color-purple" data-style="purple"></span>
                                <span class="color-red" data-style="red"></span>
                            </span>
                        </span>
                   </div>
                   <!-- END THEME CUSTOMIZER-->
                  <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                   <h3 class="page-title">
                     {$nameact}
                   </h3>
                   
                   <!-- END PAGE TITLE & BREADCRUMB-->
               </div>
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN ADVANCED TABLE widget-->
            <div class="row-fluid">
                <div class="span12">
                <!-- BEGIN EXAMPLE TABLE widget-->
                <div class="widget red">
                    <div class="widget-title">
                        <h4><i class="icon-reorder"></i> {$nameact}</h4>
                            <span class="tools">
                                <a href="javascript:;" class="icon-chevron-down"></a>
                                <a href="javascript:;" class="icon-remove"></a>
                            </span>
                    </div>
                    <div class="widget-body">
					<div class="clearfix">
                                     <div class="btn-group">
                                         <button id="editable-sample_new" class="btn green"  onclick="location.href='{$smarty.const.base_admin}?act=new-post'">
                                             Thêm bài viết <i class="icon-plus"></i>
                                         </button>
										
				{$msg}
                                     </div>
									  <table id="table">
					<tr>
						<td>
						{$listmenu}
						</td>
					</tr>
				</table>
                                 </div>
								 <div class="space15"></div>
                        <table class="table table-striped table-bordered" id="sample_1">
                            <thead>
                            <tr>
								<th width=5% style="text-align:center;"></th>
								<th width=20% style="text-align:center;">Tiêu đề</th>
								<th width=10% style="text-align:center;">Chuyên mục</th>
								<th width=30% style="text-align:center;">Miêu tả</th>
								<th width=15% style="text-align:center;">Trạng thái</th>
								<th width=10% style="text-align:center;">Tiêu điểm</th>
								<th width=10% style="text-align:center;">Hiện Trailer</th>
                            </tr>
                            </thead>
							
                            <tbody>
					{foreach from=$posts item=ps}
						<tr class="odd gradeX" onclick="doubleclick(this,'{$ps.id}');">
							<td width=5% style="position:relative;">{$ps.count}
											<div id="msg{$ps.id}" style="position:absolute;height:100%;top:0px; left:0px; width:1610%;text-align:center;display:none;font-weight:bold;text-shadow:1px 1px #fff;"></div>
											</td>
							<td width=20%><a href="{$smarty.const.base_admin}?act=edit-post&id={$ps.id}" style="color:#294871;font-weight:bold;vertical-align: middle;">{$ps.title}</a></td>
							<td width=10%>{$ps.parent}</td>
							<td width=30%>{$ps.described}</td>
							<td width=15%>{$ps.is_active}</td>
							<td width=10%><input type="checkbox" id="c_showhome{$ps.id}" value="{$ps.id}" name="is_showhome{$ps.parentid}" onclick="showhome(this.value,this.checked);" {if $ps.is_showhome eq 1} checked=''{/if}></td>
							<td width=10%><input type="checkbox" class="c_showtrailer{$ps.parentid}" id="c_showtrailer{$ps.id}" value="{$ps.id}" name="is_showtrailer{$ps.parentid}" onclick="showtrailer(this.value,this.checked,{$ps.parentid});" {if $ps.is_showtrailer eq 1} checked=''{/if}></td>
						</tr>
						
					{/foreach}
                            </tbody>
                        </table>
						<div class="pagination">
						<span class="pages">Page {$cur_page} of {$total}</span>
						{foreach from=$page item=pg}
							<a href="{$pg.link}" title="{$pg.title}">{$pg.title}</a>
						{/foreach}
					</div>
                    </div>
                </div>
                <!-- END EXAMPLE TABLE widget-->
                </div>
            </div>

            <!-- END ADVANCED TABLE widget-->
         </div>
         <!-- END PAGE CONTAINER-->
		 		<script>
		jQuery('#selectmn').on('change', function (e) { 
		window.location = "{$smarty.const.base_admin}?act=manager-post&type="+this.value;
		}); 
		</script>